/**
 * Copyright 2020 Huawei Technologies Co., Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "kernel/akg/gpu/akg_gpu_kernel_build.h"
#include <vector>
#include <memory>
#include "kernel/kernel.h"
#include "kernel/akg/akgkernelbuild.h"
#include "kernel/akg/gpu/akg_gpu_kernel_mod.h"
#include "common/utils.h"

namespace mindspore {
namespace kernel {
KernelModPtr AkgGpuKernelBuild(const AnfNodePtr &anf_node) {
  MS_EXCEPTION_IF_NULL(anf_node);
  AkgKernelBuild akg_kernel_build;

  std::vector<size_t> input_size_list;
  std::vector<size_t> output_size_list;
  KernelPackPtr kernel_pack = akg_kernel_build.BuildByJson(anf_node, &input_size_list, &output_size_list);
  MS_EXCEPTION_IF_NULL(kernel_pack);

  auto kernel_mod_ptr = std::make_shared<GpuKernelMod>(kernel_pack);
  MS_EXCEPTION_IF_NULL(kernel_mod_ptr);
  kernel_mod_ptr->SetInputSizeList(input_size_list);
  kernel_mod_ptr->SetOutputSizeList(output_size_list);
  return kernel_mod_ptr;
}
}  // namespace kernel
}  // namespace mindspore
